package main

import (
    "encoding/xml"
    "fmt"
    "io/ioutil"
    "os"
)

/*
<sysinfo type='smbios'>
  <bios>
    <entry name='vendor'>Dell Inc.</entry>
    <entry name='version'>2.4.3</entry>
    <entry name='date'>01/17/2017</entry>
    <entry name='release'>2.4</entry>
  </bios>
</sysinfo>
*/

type SysInfo struct {
    Type       string             `xml:"type,attr"`
    BIOS       *SysInfoBIOS       `xml:"bios"`
}

type SysInfoBIOS struct {
    Entry []SysInfoEntry `xml:"entry"`
}

type SysInfoEntry struct {
    Name  string `xml:"name,attr"`
    Value string `xml:",chardata"`
}

func main() {

    xmlFile, err := os.Open("sysinfo.xml")
    if err != nil {
        fmt.Println(err)
    }

    fmt.Println("Successfully Opened sysinfo.xml")
    defer xmlFile.Close()

    byteValue, _ := ioutil.ReadAll(xmlFile)

    var si SysInfo
    xml.Unmarshal(byteValue, &si)

    for _, item := range si.BIOS.Entry {
        fmt.Printf("%s: %s\n", item.Name, item.Value)
    }
}


